package com.ydc.ln.commons.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {

	private Properties props = null;

	public PropertiesUtil(String filePath) {
		props = this.getPropertiesFile(filePath);
	}

	public String getProperty(String key) {
		String value = props.getProperty(key);
		return value;
	}

	/**
	 * 
	 * 读取Properties配置文件
	 * 
	 * @param filePath
	 *            配置文件路径
	 * 
	 * @return 返回Properties数据
	 * 
	 */

	private Properties getPropertiesFile(String filePath) {
		InputStream is = this.getClass().getClassLoader().getResourceAsStream(filePath);
		Properties prop = new Properties();
		try {
			prop.load(is);
			is.close();
		} catch (IOException ex) {
			System.err.println("读取配置文件失败，配置文件路径为：" + filePath + "\n" + ex);
		}
		return prop;
	}
}
